<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	  xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
	<meta charset="UTF-8">
	<title th:text="|${application.config.webName}  登录页面|"></title>

	<div th:include="/common/layui"></div>
	<div th:include="/common/jq"></div>

	<style>
		* {
			padding: 0px;
			margin: 0px;
		}
		body {
			font-family: 微软雅黑;
			margin: 0px;
			padding: 0px;
			background: url(/image/base/bg.jpg) center center/cover no-repeat fixed;
		}
		.login-box {
			/* width: 435px; */
			width: 470px;
			/* padding: 0 30px 35px 30px; */
			padding: 0 0 35px 0;
			color: #666;
			border-radius: 4px;
			box-shadow: 1px 1px 4px #767676;
			margin: 95px auto 175px auto;
			position: relative;
		}
	</style>

</head>
<script>
	$(function() {
		$("#name").focus();
	});

	function go_login() {
		var index = layer.load(1, {
			shade : [ 0.1, '#fff' ]
			//0.1透明度的白色背景
		});

		var name = $("#name").val();
		var password = $("#password").val();

		if (name == null || name == "") {
			layer.closeAll();
			layer.msg('请输入帐号!');
			return;
		}
		if (password == null || password == "") {
			layer.closeAll();
			layer.msg('请输入密码!');
			return;
		}

		$.post('/user/login', {name : name,password : password
		}, function(result) {
			if (result.success) {
				layer.closeAll();
				window.location.href = "/admin/main";
			} else {
				layer.closeAll();
				layer.alert(result.msg);
			}
		}, 'json');

	}
</script>
<body id="app">

<div class="login-box">

	<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
		<ul class="layui-tab-title">
			<li class="layui-this">登录</li>
		</ul>
		<div class="layui-tab-content" style="height:220px;">
			<div class="layui-tab-item layui-show">
				<!-- 登录窗口 内容 -->
				<div class="layui-form" action="">
					<div class="layui-form-item">
						<label class="layui-form-label" style="width: 30px;">帐号</label>
						<div class="layui-input-block" style="margin-left: 60px;">
							<input type="text" id="name" value="admin" autocomplete="off"
								   placeholder="请输入帐号"
								   onkeydown="if(event.keyCode==13) $('#password').focus()"
								   class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label" style="width: 30px;">密码</label>
						<div class="layui-input-block" style="margin-left: 60px;">
							<input type="password" id="password" value="123456" autocomplete="off"
								   placeholder="请输入密码"
								   onkeydown="if(event.keyCode==13) go_login()"
								   class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-input-block" style="margin-left: 60px;">
							<button class="layui-btn" onclick="go_login()">登陆</button>
						</div>
					</div>
				</div>
				<!-- 登录窗口 内容 -->
			</div>
			<div class="layui-tab-item">
			</div>
		</div>
	</div>
</div>


</body>

<script>
	layui.use([ 'laydate', 'laypage', 'layer', 'table', 'carousel', 'upload',
		'element' ], function() {
		var laydate = layui.laydate //日期
				, laypage = layui.laypage //分页
				, layer = layui.layer //弹层
				, table = layui.table //表格
				, carousel = layui.carousel //轮播
				, upload = layui.upload //上传
				, element = layui.element; //元素操作

	});
</script>

</html>